package com.zgroup.domain

class StatEstate {

  String statisticsDate   //  统计日期（YYYYMMDD）
  String statisticsUnit = "20"   // 20:所有 40:年 60:月 80:天

  Integer bidCount = 0
  Integer vipCount = 0
  Integer totalCount = 0
  Integer userCount = 0

  static constraints = {
    statisticsDate(blank: false, maxSize: 8)
    statisticsUnit(blank: false, maxSize: 2)
  }

  def beforeInsert = {
    int length = statisticsDate.length()
    if (length == 2) {
      statisticsUnit = "20"
    } else if (length == 4) {
      statisticsUnit = "40"
    } else if (length == 6) {
      statisticsUnit = "60"
    } else if (length == 8) {
      statisticsUnit = "80"
    }
  }

  static belongsTo = [estate: Estate]

  String toString() {
    "id:" + id + ",statisticsDate:" + statisticsDate + ",estate:" + estate
  }
}
